" -----------------------
" main
" -----------------------
set encoding=utf-8
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim

" visual
colorscheme wombat
set guifont=Consolas:h10
set lines=40 columns=150
set guioptions-=T 

" tabulator settings
set expandtab
set tabstop=8
set softtabstop=4
set shiftwidth=4
set autoindent
:syntax on

" set search to ignore case, but only if u start to use mix case
set ignorecase
set smartcase

" -----------------------
" python
" -----------------------
autocmd FileType python set omnifunc=pythoncomplete#Complete
behave mswin
chdir c:/dev
source workspace.vim
" :cd %:p:h\
map <F2> :w\|!python %<CR>
map <A-i> :PyInteractiveREPL<CR>
" :exe ":!python " . getreg("%") . "" <CR>
" :PyInteractiveEval execfile('%')<CR>
map <A-e> :exe ":PyInteractiveEval " execfile('%')"<CR>

" -----------------------
" navigate
" -----------------------
map <C-S-p> :CtrlP c:/dev<cr>
map <F3> :TagbarToggle<CR>
map <F4> :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.vim$', '\.pyc$', '\~$']

" Map ctrl-movement keys to window switching
"map <C-k> <C-w><Up>
"map <C-j> <C-w><Down>
"map <C-l> <C-w><Right>
"map <C-h> <C-w><Left>
map <C-k> <C-w><Right>
map <C-j> <C-w><Left>

"":map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
:map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>

" navigate between tabs:
map  <C-l> :tabn<CR>
map  <C-h> :tabp<CR>
map  <C-n> :tabnew<CR>

" navigate buffers with Tab
map <C-Tab> :bnext<cr>
map <C-S-Tab> :bprevious<cr>

" close window
map <A-w> :close<CR>
"map <C-S-w> :close!<CR>

map <Tab> <C-w><C-w><cr>

" -----------------------
" other
" -----------------------
" save workspace bind
map <F12> :mksession! c:\dev\workspace.vim<CR>

" set stat it should break lines auto if more then textwidth var
set textwidth=79
set formatoptions+=t

" json
au! BufRead,BufNewFile *.json set filetype=json 

" -----------------------
" diff
" -----------------------
set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction


